
/**
 * AppleIIGo
 * Disk II Interface Card class
 * (C) 2007-2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "DiskII16SectorInterfaceCard.h"

char * diskII16SectorDriveList[] = {
	"Apple525DiskDrive",
	"Apple525DiskDrive",
	0,
};

DiskII16SectorInterfaceCard::DiskII16SectorInterfaceCard(
	Motherboard * motherboard, char * slotDeviceName) :
DiskIIController(motherboard, slotDeviceName) {
	connectDrives(diskII16SectorDriveList);
}

void DiskII16SectorInterfaceCard::onMemoryRequested() {
	romMemoryOffset = motherboard->getMemory()->requestMemory(
		DISKII16SECTORINTERFACECARD_ROM_BYTENUM);
}

void DiskII16SectorInterfaceCard::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Apple Disk II 16 Sector Interface Card P5 ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
		DISKII16SECTORINTERFACECARD_ROM_BYTENUM, romImage);
}

UINT8 DiskII16SectorInterfaceCard::readMemory(UINT16 address) {
	if (address & 0x800)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[address & 0xff];
}
